using System;
using System.Collections.Generic;
using System.Text;
using Tiago.Data;
using System.IO;

namespace NihonaidDBMerger
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                    FileInfo info1 = new FileInfo("learning_db.mdb");
                    FileInfo info2 = new FileInfo("installer_db.mdb");
                    if (info1.Exists && info2.Exists)
                    {
                        DBWrapper db_installed = new DBWrapper("learning_db.mdb", "Admin", "");
                        DBWrapper db_installer = new DBWrapper("installer_db.mdb", "Admin", "");
                        DBWrapper.Results results = db_installed.Select("*", "LearningItems");

                        for (int x = 0; x < results.getNumberRows(); x++)
                        {
                            string updates = "correct_answers = " + results.Get("correct_answers", x) + ", ";
                            updates += "wrong_answers = " + results.Get("wrong_answers", x) + ", ";
                            updates += "correct_streak = " + results.Get("correct_streak", x) + ", ";
                            updates += "last_repetition_date = '" + results.Get("last_repetition_date", x) + "', ";
                            updates += "next_repetition_date = '" + results.Get("next_repetition_date", x) + "'";
                            //updates += "mnemonic = '" + results.Get("mnemonic", x) + "'";
                            db_installer.Update("LearningItems", updates, "id = " + results.Get("id", x));
                        }
                    }
                }
            catch(Exception)
            {
            }
        }
    }
}
